﻿using PureMVC.Interfaces;
using SuperMap.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Rail.Start.Viewer
{
    class SaveAsEngineeringFormMediator : PureMVC.Patterns.Mediator, IMediator
    {
        private WorkspaceConnectionInfo m_connectionInfo = new WorkspaceConnectionInfo();
        SaveAsEngineeringForm m_ProjectFoundForm;
        public SaveAsEngineeringFormMediator(SaveAsEngineeringForm SaveAsEngineering)
               : base(NAME, SaveAsEngineering)
        {
            m_ProjectFoundForm = SaveAsEngineering;
            InitialEvent();
        }
        private void InitialEvent()
        {
            m_ProjectFoundForm.ButtonSaveAs.MouseClick += SaveAsEvent;
            m_ProjectFoundForm.BrowseButton.MouseClick += BrowseEvent;
        }
        private void SaveAsEvent(object sender, EventArgs e)
        {
            m_connectionInfo.Type = WorkspaceType.SMWU;
            m_connectionInfo.Server = FormMain.formMain.m_sampleRun.m_connectionInfo.Server;
            FormMain.formMain.m_sampleRun.SaveAs(m_connectionInfo);
        }
        private void BrowseEvent(object sender,EventArgs e)
        {
            FolderBrowserDialog folderBrowserDig = new FolderBrowserDialog();

            if (folderBrowserDig.ShowDialog() == DialogResult.OK)
            {
                m_ProjectFoundForm.TextBoxFilePath.Text = folderBrowserDig.SelectedPath;
            }
        }
    }
}
